package Fundation;

import java.util.*;

public class Arrayall {
    public static void main(String[] args) {
        //数组Array
        int[] arr={1,3,5,4,2};
        System.out.println(arr);
        System.out.println(arr[0]);
        System.out.println(Arrays.toString(arr));
        Arrays.sort(arr);
        System.out.println(Arrays.toString(arr));
        
        //以下都是集合Collection
        //List接口实现（ArrayList）
        List<String> list=new ArrayList<>();
        list.add("apple");
        list.add("banana");
        list.add("orange");
        System.out.println(list);

        List<Integer> numbers = new ArrayList<>();
        numbers.add(5);
        numbers.add(1);
        numbers.add(3);
        numbers.add(2);
        numbers.add(4);
        Collections.sort(numbers);
        System.out.println(numbers);

        //Set接口实现（HashSet）:不会添加重复项1 2 2
        Set<Integer> set=new HashSet<>();
        set.add(1);
        set.add(2);
        set.add(2);
        System.out.println(set);

        //Map接口实现（HashMap）:value-key
        Map<String,Integer> map=new HashMap<>();
        map.put("one",1);
        map.put("two",2);
        System.out.println(map);

        //队列Queue实现LinkedList
        Queue<Integer> queue=new LinkedList<>();
        queue.offer(2);
        queue.offer(5);
        queue.offer(4);
        System.out.println("队列出列："+queue.poll());
        System.out.println("队列出列后剩余："+queue);

        //栈Stack实现
        Stack<Integer> stack=new Stack<>();
        stack.push(1);
        stack.push(2);
        stack.push(3);
        System.out.println("栈出列："+stack.pop());
        System.out.println("栈出列后剩余："+stack);
    }
}
